<template>
  <div>
    <span v-if="prop != 'todo_list'">{{ row[prop] }}</span>
    <div v-if="prop == 'todo_list'">
      <el-link v-for="(item, index) in row.todo_list" :key="index" :type="item.type" :size="item.size"
        @click="handleClick(item.click)" style="margin-left: 10px">{{ item.name }}</el-link>
    </div>
  </div>
</template>

<script>
// import api from "../../../utils/api";
// import bidMixin from "../../../minxins/projectMixin";
export default {
  // mixin: [bidMixin],
  name: "iCell",
  props: ["prop", "row"],
  data() {
    return {
      // 录入投标结果状态值
    };
  },
  methods: {
    // ==========================================
    handleClick(i) {
      let onClick = i;
      this[onClick]();
    },
    // ====================
    // 编辑
    editData() {
      // 编辑投标
      // 跳转至pages/editBit
      // 回显对应项目内容

      // ============================
      // 混入数据未获取到？？？？？？？？？？？？？？？？？？？？？？？
      console.log(this.bid_tableData);

      this.$router.push({
        name: "editBid",
        // params: {
        //   id: this.bid_tableData[0].id
        // }
      });
    },
    // 删除
    delData() {
      // 删除
      // 删除弹窗
      this.$confirm(
        "<h3>是否确认删除该投标</h3><p>删除后将不可恢复</p>",
        "删除确认",
        {
          dangerouslyUseHTMLString: true,
          confirmButtonText: "确定",
          cancelButtonText: "取消",
        }
      )
        .then(() => {
          this.$message({
            type: "success",
            message: "删除成功!",
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    // 详情
    checkData() {
      // 详情
      // 跳转至pages/bidDetails
      this.$router.push("/project/bid/bidDetails");
    },
    // 进度更新
    progressUpdate() {
      // 进度更新
      // 进度更新弹窗
      this.$confirm("插入表格", "进度更新", {
        distinguishCancelAndClose: true,
        dangerouslyUseHTMLString: true,
        confirmButtonText: "保存",
        cancelButtonText: "放弃修改",
      })
        .then(() => {
          this.$message({
            type: "info",
            message: "保存修改",
          });
        })
        .catch((action) => {
          this.$message({
            type: "info",
            message:
              action === "cancel" ? "放弃保存并离开页面" : "停留在当前页面",
          });
        });
    },
    // 录入投标结果
    biddingResults() {
      // 录入投标结果
      // 需要对状态值进行判断
      // 弹出对应的弹框（未完成/已完成）

      // 投标未完成
      this.$alert(
        "<h3>当前投标工作还未完成不支持录入中标结果操作</h3><p>请先更新投标工作进度为已完成</p>",
        "录入投标结果",
        {
          dangerouslyUseHTMLString: true,
          confirmButtonText: "确定",
          callback: (action) => {
            this.$message({
              type: "info",
              message: `action: ${action}`,
            });
          },
        }
      );

      // 投标已完成(待定)
      const h = this.$createElement;
      this.$msgbox({
        title: "录入投标结果",
        message: h("div", null, [
          h("div", null, [
            h("span", null, "是否中标"),
            h("el-switch", {
              style: "active-color:#13ce66;inactive-color:#ff4949",
            }),
          ]),
        ]),
        showCancelButton: true,
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        beforeClose: (action, instance, done) => {
          if (action === "confirm") {
            instance.confirmButtonLoading = true;
            instance.confirmButtonText = "执行中...";
            setTimeout(() => {
              done();
              setTimeout(() => {
                instance.confirmButtonLoading = false;
              }, 300);
            }, 3000);
          } else {
            done();
          }
        },
      }).then((action) => {
        this.$message({
          type: "info",
          message: "action: " + action,
        });
      });
    },
  },
};
</script>

<style>
</style>